package com.demo.eshop.pdetail.service.user.impl;

import com.alibaba.fastjson.JSON;
import com.demo.eshop.pdetail.dao.RedisDao;
import com.demo.eshop.pdetail.entity.User;
import com.demo.eshop.pdetail.mapper.UserMapper;
import com.demo.eshop.pdetail.service.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: e20160504
 * @date: 2018/10/17
 * @desc
 */

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private RedisDao redisDao;


    @Override
    public User getUserInfo() {
        return userMapper.selectOne(new User());
    }

    /**
    *@params:
    *@return:
    *@desc:  查询redis用户信息
    */
    @Override
    public User getCacheUserInfo() {
        redisDao.set("kevin","{\"userName\":\"kevin\",\"age\":18}");
        String kevin = redisDao.get("kevin");
        User user = JSON.parseObject(kevin, User.class);
        return user;
    }


}
